<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <script src="./XDOMEvent.js"></script>
</head>
<body>
<button id="btn">点击</button>

<script>
var e = new XDOMEvent();
var btn = document.getElementById('btn');

function Demo() {
    this.init();
    
    this.unbind = function() {        
        e.removeEventListener(btn, 'click', this.say);
        
        console.log('click event of btn has been removed.');
    }
}
Demo.prototype.init = function() {    
    e.addEventListener(btn, 'click', this.say, this);
    
    console.log('click event has attached to btn.');
}
Demo.prototype.say = function(e) {
    this.unbind()
};



new Demo();

</script>
</body>
</html>
